/*

 * XXX
 */

package edu.uhcl.csci4838.group3.pendingIntents;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import edu.uhcl.csci4838.group3.pendingIntents.notifications.ReminderService;
import edu.uhcl.csci4838.group3.pendingIntents.ringer.RingerChange;

/**
 * XXX
 * 
 * @author Tyler Hays
 */
public class OnAlarmReceiver extends BroadcastReceiver {
	
	/**
	 * used for debugging
	 */
	private static final String TAG = "onAlarmReciver";
	
	/**
	 * recieves alarm
	 * 
	 * @param context
	 *            {@inheritDoc}
	 * @param intent
	 *            {@inheritDoc}
	 */
	/* 
	 * (non-Javadoc)
	 * 
	 * @see android.content.BroadcastReceiver#onReceive(android.content.Context, android.content.Intent)
	 */
	@Override
	public void onReceive(final Context context,
			final Intent intent) {
		WakeUpReminderIntentService.acuireStaticLock(context);
		Intent i;
		Log.d(OnAlarmReceiver.TAG,
				"Recieved wake up cal from Alarm Manger");
		if (intent.getStringExtra(IntentExtraStringStorage.TABLE_NAME)
				.equals(IntentExtraStringStorage.RINGER_CHANGE) == true) {
			i = new Intent(context,
					RingerChange.class);
			i.putExtras(intent.getExtras());
			Log.d(OnAlarmReceiver.TAG,
					"Ringer Change");
			context.startService(i);
			
		} else {
			i = new Intent(context,
					ReminderService.class);
			i.putExtras(intent.getExtras());
			Log.d(OnAlarmReceiver.TAG,
					"Launched task");
			context.startService(i);
		}
		
		
	}
	
}
